void main() {
  // 准备购物车数据
  List carts = [
    {"count": 2, "price": 10.0, "selected": true},
    {"count": 1, "price": 30.0, "selected": false},
    {"count": 5, "price": 20.0, "selected": true}
  ];

  // 调用封装的函数
  bool isSelectedAll = getSelectedState(carts);
  if (isSelectedAll) {
    print('全选');
  } else {
    print('非全选');
  }
}

// 核心逻辑：只要有任何一个商品是未勾选的，那么就是非全选
// 函数名称 getSelectedState

bool getSelectedState(List carts) {
  bool isSelectedAll = true;
  carts.forEach((item) {
    if (!item["selected"]) {
      isSelectedAll = false;
    }
  });
  return isSelectedAll;
}
